package org.spbsu.apco.common.task.impl;

import org.spbsu.apco.common.data.core.FileData;
import org.spbsu.apco.common.task.core.BaseTask;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;

/**
 * User: solozobov
 * Date: 25.11.12
 */

public class ScreenshotTask extends BaseTask<String, FileData> {
    @Override
    public FileData execute(final List<String> inputData) throws Exception {
        final Robot robot = new Robot();
        final BufferedImage screenshot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
        final File result = new File("screenshot.jpg");
        ImageIO.write(screenshot, "JPG", result);

        return new FileData(inputData.get(0), result);
    }
}
